home *** CD-ROM | disk | FTP | other *** search
- // HTBDisp
-
- // example for direct access to exported functions from HTBWin.exe and htbwrun.exe
-
-
- #include <windows.h>
-
-
- typedef void ( * lpDisp)(char *);
- typedef void ( * lphBasicWindow)();
-
- lpDisp fpDisp = NULL;
- lphBasicWindow fphBasicWindow = NULL;
-
- HINSTANCE hHTBWin;
-
-
- extern "C"
- {
-
- /////////////////////////////////////////////////////////////////////////////////////////////////////////
-
- // Function name : InitHTB
- // Description : initalize function pointer for disp function exported from htbwin.exe
- // Return type : BOOL
- BOOL InitHTB()
- { BOOL result = TRUE;
-
- hHTBWin = LoadLibrary("HTBwin.exe");
-
- if (hHTBWin != NULL)
- { fphBasicWindow = (lphBasicWindow)GetProcAddress(hHTBWin,"g_hBasicWindow");
-
- if (fphBasicWindow == NULL)
- { FreeLibrary(hHTBWin);
- result = FALSE;
- }
- }
- else
- { result = FALSE;
- }
-
- if (result == FALSE)
- { hHTBWin = LoadLibrary("HTBwrun.exe");
-
- if (hHTBWin != NULL)
- { fphBasicWindow = (lphBasicWindow)GetProcAddress(hHTBWin,"g_hBasicWindow");
-
- if (fphBasicWindow == NULL)
- { FreeLibrary(hHTBWin);
- result = FALSE;
- }
- else
- { result = TRUE;
- }
- }
- }
-
- if (result == TRUE)
- { fpDisp = (lpDisp)GetProcAddress(hHTBWin,"Disp");
-
- if (fpDisp == NULL)
- { result = FALSE;
- }
- }
-
- return(result);
- }
-
-
- ///////////////////////////////////////////////////////////////////////////////////////////////////////
-
- // Function name : Disp
- // Description : exported function that calls back into htbasic's exported disp function
- // Return type : void
- // Argument : char * msg
- void Dlldisp(char * msg)
- { if (fpDisp == NULL)
- { BOOL result = InitHTB();
-
- if (!result)
- { return;
- }
- }
-
- fpDisp(msg);
- }
-
-
-
- } // end extern "C"